import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WarehouseVO, WarehouseForm, WarehouseQuery } from '@/api/wmscloud/warehouse/types';

/**
 * 查询仓库列表
 * @param query
 * @returns {*}
 */

export const listWarehouse = (query?: WarehouseQuery): AxiosPromise<WarehouseVO[]> => {
  return request({
    url: '/wmsCloud/warehouse/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询仓库详细
 * @param warehouseId
 */
export const getWarehouse = (warehouseId: string | number): AxiosPromise<WarehouseVO> => {
  return request({
    url: '/wmsCloud/warehouse/' + warehouseId,
    method: 'get'
  });
};

/**
 * 新增仓库
 * @param data
 */
export const addWarehouse = (data: WarehouseForm) => {
  return request({
    url: '/wmsCloud/warehouse',
    method: 'post',
    data: data
  });
};

/**
 * 修改仓库
 * @param data
 */
export const updateWarehouse = (data: WarehouseForm) => {
  return request({
    url: '/wmsCloud/warehouse',
    method: 'put',
    data: data
  });
};

/**
 * 删除仓库
 * @param warehouseId
 */
export const delWarehouse = (warehouseId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/warehouse/' + warehouseId,
    method: 'delete'
  });
};

/**
 * 打印仓库
 * @param warehouseId
 */
export const printWarehouse = (warehouseId: string | number )=> {
  return request({
    url: '/wmsCloud/warehouse/printWarehouse/' + warehouseId,
    method: 'get',
    responseType: 'arraybuffer',
    headers: {
      'Content-Type': 'application/json'
    },
  })
}
